$(function () {
    var ue = UE.getEditor('ueditor',{
        'serverUrl':'/ueditor/upload/',
        toolbars: [
    [
        'undo', //撤销
        'redo', //重做
        'bold', //加粗
        'indent', //首行缩进
        'snapscreen', //截图
        'italic', //斜体
        'underline', //下划线
        'strikethrough', //删除线
        'source', //源代码
        'blockquote', //引用
        'insertcode', //代码语言
        'simpleupload', //单图上传
        'emotion', //表情
        'spechars', //特殊字符
        'forecolor', //字体颜色
        'attachment', //附件
        'background', //背景
        'charts' // 图表
    ]
]
    })
    window.ue = ue;
});
$(function () {
   $('#add-comment').click(function (event) {
       event.preventDefault();
       var loginTag = $('#login-tag').attr('data-is-login');
       if(!loginTag){
           window.location ='/signin/'
       }else {
           var content = window.ue.getContent()
           var post_id = $('#post-content').attr('data-id')
           zlajax.post({
               'url':'/acomment/',
               'data':{
                   'content':content,
                   'post_id':post_id
               },
               'success':function (data) {
                   if(data['code'] == 200){
                       window.location.reload()
                   }else{
                       xtalert.alertInfo(data['message'])
                   }
               }
           })
       }

   })
});
$(function () {
    var ue1 = UE.getEditor('ueditor1',{
        'serverUrl':'/ueditor/upload/',
        toolbars: [
    [
        'undo', //撤销
        'redo', //重做
        'bold', //加粗
        'indent', //首行缩进
        'italic', //斜体
        'underline', //下划线
        'insertcode', //代码语言
        'source', //源代码
        'blockquote', //引用
        'simpleupload', //单图上传
    ]
]
    })
    window.ue1 = ue1;
});
$(function () {
   $('.comment-reply-btn').click(function (event) {
       event.preventDefault();
       var self = $(this);
       var p = self.parent();
       var postidInfo = p.attr('data-post-id').val;
       var commentidInfo = p.attr('data-comment-id').val;
       var contentInfo = p.attr('data-content').val;

       // var post_id = postidInfo.val();
       // var comment_id = commentidInfo.val();
       // var content = contentInfo.val();

       zlajax.post({
           'url':'/rcomment/',
           'data':{
               'post_id':post_id,
               'comment_id':comment_id,
               'content':content
           },
           'success':function (data) {
               if (data['code'] == 200){
                   window.location.reload()
               }else {
                   xtalert.alertInfo(data['message'])
               }
           }
       })

   })
});